import sbt.Keys._
import sbt._

object buildsettings {

  val commonSettings: Seq[Setting[_]] = Seq(
    organization := """""",
    version := "0.1-SNAPSHOT",
    scalaVersion := "2.12.4",
    resolvers ++= Seq(
      Resolver.sonatypeRepo("releases"),
      Resolver.jcenterRepo,
      Resolvers.TwitterMaven,
      Resolvers.FinatraRepo,
      Resolvers.ScalazBintray,
      Resolvers.LocalMaven
    )
  )

  val _scalacOptions = Seq(
    "-deprecation",
    "-encoding",
    "UTF-8",
    "-feature",
    "-language:existentials",
    "-language:higherKinds",
    "-language:implicitConversions",
    "-language:postfixOps",
    "-language:experimental.macros",
    "-unchecked",
    "-Ywarn-nullary-unit",
    "-Xfatal-warnings",
    "-Ywarn-dead-code",
    "-Xfuture"
  )

  object Versions {

    val slf4jVersion            = "1.7.24"
    val scalaLoggingVersion     = "3.7.2"
    val slickVersion            = "3.1.1"
    val circeVersion            = "0.6.1"
    val akkaVersion             = "2.4.18"
    val akkaHttpVersion         = "10.0.0"
    val akkaHttpJsonVersion     = "1.19.0"
    val akkaHttpSessionVersion  = "0.3.0"
    val ficusVersion            = "1.4.1"
    val catsVersion             = "0.8.1"
    val swaggerVersion          = "1.5.12"
    val kylinVersion            = "1.6.0"
    val opencsvVersion          = "3.9"
    val chillVersion            = "0.9.2"
    val mongodbVersion          = "2.2.0"
    val scalaTestVersion        = "3.0.4"
    val typesafeConfigVersion   = "1.3.1"
    val elastic4sCore           = "2.4.0"
    val jodaConvertVersion      = "1.7"
    val jodaTimeVersion         = "2.8.2"
    val wxPayVersion            = "2.9.0"
    val redisclient             = "3.4"
    val mockito                 = "1.9.5"
    val sangriaVersion          = "1.4.0"
    val sangriaCirceVersion     = "1.2.1"
    val sangriaSprayJsonVersion = "1.0.1"
    val sangriaPlayJsonVersion  = "1.0.4"
    val scalaCheck              = "1.13.4"
    val scalaGuice              = "4.1.0"
    val scalaTest               = "3.0.0"
    val playJsonVersion         = "2.6.7"
    val logbackVersion          = "1.2.3"
  }

  object Librarys {

    import Versions._

    val cats           = "org.typelevel"              %% "cats"               % catsVersion
    val commonsIo      = "commons-io"                 % "commons-io"          % "2.4"
    val elastic4s      = "com.sksamuel.elastic4s"     %% "elastic4s-core"     % elastic4sCore
    val ficus          = "com.iheart"                 %% "ficus"              % ficusVersion
    val guava          = "com.google.guava"           % "guava"               % "18.0"
    val jodaConvert    = "org.joda"                   % "joda-convert"        % jodaConvertVersion
    val jodaTime       = "joda-time"                  % "joda-time"           % jodaTimeVersion
    val log4japi       = "org.apache.logging.log4j"   % "log4j-api"           % "2.8.2"
    val log4jSlf4jImpl = "org.apache.logging.log4j"   % "log4j-slf4j-impl"    % "2.8.2"
    val mongodb        = "org.mongodb.scala"          %% "mongo-scala-driver" % mongodbVersion
    val openCsv        = "com.opencsv"                % "opencsv"             % opencsvVersion
    val playJsonJoda   = "com.typesafe.play"          %% "play-json-joda"     % playJsonVersion
    val redisclient    = "net.debasishg"              %% "redisclient"        % Versions.redisclient
    val scalaLogging   = "com.typesafe.scala-logging" %% "scala-logging"      % scalaLoggingVersion
    val sigarLoader    = "io.kamon"                   % "sigar-loader"        % "1.6.6-rev002"
    val slf4japi       = "org.slf4j"                  % "slf4j-api"           % slf4jVersion
    val typesafeConfig = "com.typesafe"               % "config"              % typesafeConfigVersion
    val weChatPay      = "com.github.binarywang"      % "weixin-java-pay"     % wxPayVersion
    val logback        = "ch.qos.logback"             % "logback-classic"     % logbackVersion

    // Akka
    val akka: Seq[ModuleID] =
      Seq("com.typesafe.akka" %% "akka-slf4j", "com.typesafe.akka" %% "akka-actor").map(_ % akkaVersion)
    // Akka-Http
    val akkaHttp: Seq[ModuleID] = Seq("com.typesafe.akka" %% "akka-http", "com.typesafe.akka" %% "akka-http-core")
      .map(_ % akkaHttpVersion) :+ "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test
    val akkaHttpJson    = Seq("de.heikoseeberger"                  %% "akka-http-play-json" % akkaHttpJsonVersion)
    val akkaHttpSession = Seq("com.softwaremill.akka-http-session" %% "core"                % akkaHttpSessionVersion)
    // Circe
    val circe: Seq[ModuleID] =
      Seq("io.circe" %% "circe-core", "io.circe" %% "circe-generic", "io.circe" %% "circe-jawn").map(_ % circeVersion)
    // GraphQL
    val sangria: Seq[ModuleID] = Seq(
      "org.sangria-graphql" %% "sangria" % sangriaVersion,
      //"org.sangria-graphql" %% "sangria-circe" % sangriaCirceVersion,
      //"org.sangria-graphql" %% "sangria-json4s-jackson" % "1.0.0",
      //"org.sangria-graphql" %% "sangria-json4s-native" % "1.0.0",
      //"org.sangria-graphql" %% "sangria-spray-json" % sangriaSprayJsonVersion,
      "org.sangria-graphql" %% "sangria-play-json" % sangriaPlayJsonVersion
    )
    //    "org.sangria-graphql" %% "sangria" % "1.1.0",
    //    "org.sangria-graphql" %% "sangria-spray-json" % "1.0.0",
    // "org.sangria-graphql" %% "sangria-circe" % "1.2.1"

    val akkaModule: Seq[ModuleID]   = Seq(akka, akkaHttp, akkaHttpJson, akkaHttpSession).flatten
    val commonModule: Seq[ModuleID] = Seq(ficus, jodaTime, jodaConvert, logback, typesafeConfig)
    val loggingModule               = Seq(slf4japi, log4japi, log4jSlf4jImpl, scalaLogging)
    val unitTestingModule = Seq(
      "org.mockito"    % "mockito-core" % Versions.mockito    % "test",
      "org.scalacheck" %% "scalacheck"  % Versions.scalaCheck % "test",
      "org.scalatest"  %% "scalatest"   % Versions.scalaTest  % "test"
    )
  }

  object Dependencies {

    import Librarys._

    val designer: Seq[ModuleID] = akkaModule ++ commonModule ++ sangria ++
      Seq(mongodb, openCsv, playJsonJoda) ++ unitTestingModule

    val fileServer: Seq[ModuleID] = unitTestingModule
  }

  object Resolvers {

    val TwitterMaven        = "Twitter Maven".at("https://maven.twttr.com")
    val FinatraRepo         = "Finatra Repo".at("http://twitter.github.com/finatra")
    val ScalazBintray       = "scalaz-bintray".at("http://dl.bintray.com/scalaz/releases")
    val Snapshots           = "snapshots".at("http://oss.sonatype.org/content/repositories/snapshots")
    val SonatypeReleases    = "releases".at("http://oss.sonatype.org/content/repositories/releases")
    val SonatypeOSSReleases = "Sonatype OSS Releases".at("https://oss.sonatype.org/service/local/staging/deploy/maven2")
    val LocalMaven          = "Local Maven Repository".at("file://" + Path.userHome.absolutePath + "/.ivy2")
    val MavenMirrorid       = "maven.mirrorid".at("http://mirrors.ibiblio.org/pub/mirrors/maven2/")
    val TypesafeSnapshots   = "Typesafe Snapshots".at("http://repo.typesafe.com/typesafe/snapshots/")
    val TypesafeRepository  = "Typesafe Repository".at("http://repo.typesafe.com/typesafe/releases/")
  }
}
